package org.tim.es.webapi;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.tim.es.message.UserPrivateMessage;
import org.tim.es.message.UserPrivateMessageResource;

@RestController
@RequestMapping("/private_message")
public class PrivateMessageController {

    @Autowired
    private UserPrivateMessageResource privateMessageResource;

    @GetMapping
    @ApiOperation("获取当前会话的聊天记录")
    public Page<UserPrivateMessage> findManyBySession(@RequestParam String sessionId,
                                                      @RequestParam(required = false, defaultValue = "0") Integer page,
                                                      @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        return privateMessageResource.findAllBySessionId(sessionId, page, pageSize);
    }
}
